from flask import Flask
from flask import Blueprint
from flask_restful import Api


def register_app_routers(app: Flask):

    from flask_shop.apis.api_map import routers
    """注册路由函数"""
    for module, item in routers.items():
        bp = Blueprint(name=module, import_name=__name__, url_prefix=f'/api/{module}')
        api = Api(bp)
        for url, func in item.items():
            api.add_resource(func, url)
        app.register_blueprint(bp)
